<?php
/**
 *
 * @version $Id: CParameterIterator.php,v 1.3 2011-06-17 04:43:21 herve Exp $
 * @copyright 2011
 * @since 1.0
 */
class CParameterIterator implements Iterator {

	public static $ROW_ITERATION = 0;
	public static $COL_ITERATION = 1;

	protected $_parameter = null;
	protected $_keys = null;
	protected $_currentIdx = -1;

	public function __construct($parameter, $iterationMode = 0) {
		$this->_parameter = $parameter;
		if ($iterationMode != self::$COL_ITERATION) {
			$this->_keys = $parameter->getIndices();
		} else {
			$this->_keys = array_keys($parameter->getHeaders());
		}
		$this->rewind();
	}

	public function current() {
		return ($this->_parameter[$this->key()]);
	}

	public function key() {
		return $this->_keys[$this->_currentIdx];
	}

	public function next() {
		$this->_currentIdx++;
	}

	public function rewind() {
		$this->_currentIdx = 0;
	}

	public function valid() {
		return ($this->_currentIdx >= 0 && $this->_currentIdx < count($this->_keys));
	}

}
?>
